package com.g4.shoppingsingle.mapper;

import com.g4.shoppingsingle.dto.CartInfoDTO;
import com.g4.shoppingsingle.pojo.DdCartDetail;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* <p>
    * 购物车表 Mapper 接口
    * </p>
*
* @author admin
* @since 2021-10-27
*/
@Mapper
public interface DdCartDetailMapper extends BaseMapper<DdCartDetail> {

    /**
     * 根据用户id获取用户的购物车列表
     * @param userId
     * @return
     */
    @Select("SELECT c.*,k.discount_price FROM dd_cart_detail c,dd_kind_type k WHERE c.pd_id = k.pd_id AND c.type_id = k.id AND c.user_id=#{userId}")
    List<CartInfoDTO> selectCartByUserId(Integer userId);



}
